<template>
    <div class="container">
       <Tab  style="position:fixed; background-color:#fff; z-index:999"/>

     <van-list
  v-model="loading"
  :finished="finished"
  finished-text="没有更多了"
  @load="onLoad"
>
<li class="header">
      <span>申请人</span>
      <span>申请时间</span>
      <span>状态</span>
    </li>
    <div style="height:110px"></div>
  <ul v-for="item in list" :key="item.id">
    <li @click="select(item)">
      <span style="width:25%">{{item.approver_name}}</span>
      <span style="width:44%">{{item.apply_time}}</span>
      <van-button round  size="mini" type="primary" style="width:20%;font-size:10px;">{{item.whether_end}}</van-button>
    </li>
  </ul>
</van-list>
    </div>
</template>
<script>
import BScroll from '@better-scroll/core'
import axios from 'axios'
import {getCookie} from 'Utils/cookie'
import Tab from 'Comp/Tab'
export default {
  
  data(){
    return{
       list: [],
      loading: false,
      finished: false,
      pagelimit:1,
       
    }
  },
  components:{
    Tab,
  },
  computed:{
  },
  methods:{
    // 上拉加载
    onLoad() {
         axios({
      url:'/hrkc/Product/getApplyList',
      method:'POST',
      params:{
         pagesize:10,
         pagelimit:this.pagelimit,
         whether_end:'ing',
         org_code:getCookie('org_no'),
         approver_id:getCookie('approver_id')
        },
    }).then(res=>{
      console.log('res1111',res)
      if(res.data.code == 0){

        for (let i = 0; i < res.data.data.length; i++) {
          
           var item = {};
            item.approver_name = res.data.data[i].approver_name;
            console.log('apply_time',res.data.data[i].apply_time)

            item.apply_time =  res.data.data[i].apply_time.substring(0,res.data.data[i].apply_time.length-5);
            item.apply_id = res.data.data[i].id;
            item.approver_id = res.data.data[i].approver_id
            if(res.data.data[i].whether_end == 'ing'){
              item.whether_end = '正在进行中';
            }
            
            this.list.push(item);

          //this.list.push(res.data.data[i].approver_name+" "+res.data.data[i].apply_time+" "+res.data.data[i].whether_end);
        }
        this.pagelimit = this.pagelimit+1;
      }else{
        this.finished = true;
      }
      this.loading = false;
    }).catch(error =>Promise.reject(error))
    },

    select(item){
      console.log(item)

      this.$router.push({
        path:'/check',
        query:{
          data:JSON.stringify(item)
        }
      })
    }
  },
  mounted(){
    
    
  }
  

}
</script>
<style lang="scss" scoped>
.header{
  width:100%;
  height:50px;
  position:fixed; 
  top:50px; 
  background-color:#fff;
}

li {
  height:30px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-bottom: 1px solid #ccc;
}
</style>
